package com.bins.cloud.stream.mq;

import com.bins.cloud.stream.eo.mq.MqMsg;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

import java.util.UUID;
import java.util.function.Supplier;

@Slf4j
// @Component
public class MqProducer {

    @Bean
    public Supplier<Message<MqMsg>> topicBProducer() {
        log.info("topicBProducer开始发送消息");
        return () -> {
            MqMsg mqMsg = new MqMsg();
            mqMsg.setId(UUID.randomUUID().toString());
            mqMsg.setName(Thread.currentThread().getName());
            log.info("receiveMq 发送一条记录：" + mqMsg);
            return MessageBuilder.withPayload(mqMsg).build();
        };
    }

}
